package com.laputacastle.dr.mapper;

import com.laputacastle.dr.model.DrContentImgs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

/**
* Created by Mybatis Generator 2020/01/17
*/
@Repository
public interface DrContentImgsMapper {
    @Delete({
        "delete from t_dr_content_imgs",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String cId);

    @Insert({
        "insert into t_dr_content_imgs (c_id, c_demorecord_id, ",
        "c_img_name, dt_creat_time, ",
        "dt_update_time)",
        "values (#{cId,jdbcType=VARCHAR}, #{cDemorecordId,jdbcType=VARCHAR}, ",
        "#{cImgName,jdbcType=VARCHAR}, #{dtCreatTime,jdbcType=TIMESTAMP}, ",
        "#{dtUpdateTime,jdbcType=TIMESTAMP})"
    })
    int insert(DrContentImgs record);

    @InsertProvider(type=DrContentImgsSqlProvider.class, method="insertSelective")
    int insertSelective(DrContentImgs record);

    @Select({
        "select",
        "c_id, c_demorecord_id, c_img_name, dt_creat_time, dt_update_time",
        "from t_dr_content_imgs",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="c_id", property="cId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="c_demorecord_id", property="cDemorecordId", jdbcType=JdbcType.VARCHAR),
        @Result(column="c_img_name", property="cImgName", jdbcType=JdbcType.VARCHAR),
        @Result(column="dt_creat_time", property="dtCreatTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="dt_update_time", property="dtUpdateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    DrContentImgs selectByPrimaryKey(String cId);

    @UpdateProvider(type=DrContentImgsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DrContentImgs record);

    @Update({
        "update t_dr_content_imgs",
        "set c_demorecord_id = #{cDemorecordId,jdbcType=VARCHAR},",
          "c_img_name = #{cImgName,jdbcType=VARCHAR},",
          "dt_creat_time = #{dtCreatTime,jdbcType=TIMESTAMP},",
          "dt_update_time = #{dtUpdateTime,jdbcType=TIMESTAMP}",
        "where c_id = #{cId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(DrContentImgs record);
}